/**   
 * @Title: A.java 
 * @Package com.hanyong.admin.controller.vip 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author Li  
 * @date 2018年6月7日 下午4:57:53 
 * @version V1.0   
 */
package com.hyfrogx.modules.zoom.controller;

import com.hyfrogx.common.exception.MyException;
import com.hyfrogx.common.utils.R;
import com.hyfrogx.common.validator.ValidatorUtils;
import com.hyfrogx.modules.sys.controller.AbstractController;
import com.hyfrogx.modules.zoom.param.ZoomJoinPrice;
import com.hyfrogx.modules.zoom.param.ZoomPirce;
import com.hyfrogx.modules.zoom.service.MeetJoinPriceService;
import com.hyfrogx.modules.zoom.service.MeetPriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * @ClassName: 会议定价
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author Li
 * @date 2018年6月7日 下午4:57:53
 * 
 */
@RestController
@RequestMapping("/fix/meetPrice")
@Api(value = "开会收费价格管理controller", tags = {"后台--会议定价管理"})
public class MeetPriceController extends AbstractController {

	@Autowired
	MeetPriceService meetPriceService;

	@Autowired
	MeetJoinPriceService meetJoinPriceService;

	/**
	 * 获取开会系统收费相关参数
	 *
	 * @param
	 * @return zoomPirce
	 * @throws MyException
	 */
	@GetMapping("/get")
	@ApiOperation("获取开会系统收费相关参数")
	public R getMeetPrice() {
		try {
			ZoomPirce zoomPirce = meetPriceService.getMeetPriceObject();
			return R.ok().put("data",zoomPirce);
		} catch (MyException e) {
			return R.error(e.getMessage());
		}
	}


	/**
	 * 编辑开会系统收费相关参数
	 *
	 * @param zoomPirce
	 * @return
	 */
	@PostMapping("/edit")
	@ApiOperation("编辑开会系统收费相关参数")
	public R editMeetParam(@RequestBody ZoomPirce zoomPirce) {
		try {
			ValidatorUtils.validateClientEntity(zoomPirce);
			meetPriceService.editMeetPrice(zoomPirce);
			return R.ok("更新成功");
		} catch (Exception e) {
			return R.error(e.getMessage());
		}
	}


	/**
	 * 获取参会系统收费相关参数
	 *
	 * @param
	 * @return
	 */
	@GetMapping(value = "get/baiscJoin")
	@ApiOperation("获取参会系统收费相关参数")
	public R getBasicJoinMeetPrice() {
		try {
			ZoomJoinPrice zoomJoinPrice = meetJoinPriceService.getMeetPriceObject();
			return R.ok().put("data",zoomJoinPrice);
		} catch (Exception e) {
			return R.error(e.getMessage());
		}
	}


	/**
	 * 编辑参会系统收费相关参数
	 *
	 * @param zoomJoinPrice
	 * @return
	 */
	@PostMapping("/edit/baiscJoin")
	@ApiOperation("编辑参会系统收费相关参数")
	public R editBasicJoinMeetParam(@RequestBody ZoomJoinPrice zoomJoinPrice) {
		try {
			ValidatorUtils.validateClientEntity(zoomJoinPrice);
			meetJoinPriceService.editMeetPrice(zoomJoinPrice);
			return R.ok("更新成功");
		} catch (MyException e) {
			return R.error(e.getMessage());
		}
	}



}
